<?php
/**
 * Digits rule
 * Validates that value consists of only digits. Optionally allows whitespace.
 *
 * @package     Q-Validate
 * @subpackage  Rules
 * @author      Luke Visinoni <luke.visinoni@gmail.com>
 * @copyright   (c) 2010 Luke Visinoni <luke.visinoni@gmail.com>
 * @version     $Id: Digits.php 37 2010-12-23 02:38:44Z luke.visinoni $
 */
class Q_Rule_Digits extends Q_Rule_Abstract {

    /**
     * The parameters that were passed to this rule
     */
    protected $_params = array(
        'whitespace' => false,
    );
    public function isValid($value) {
    
        $pattern = ($this->getParam('whitespace')) ? '/^[0-9\s]+$/' : '/^[0-9]+$/';
        return $this->_validatePattern($pattern, $value);
    
    }

}
